package com.jboa.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.jboa.dao.UserRoleDao;
import com.jboa.model.UserRole;


public class UserRoleDaoImpl extends HibernateDaoSupport implements UserRoleDao {

	public void delete(UserRole entity) {
		super.getHibernateTemplate().delete(entity);

	}

	public List<UserRole> findBy2Properties(String propertyName1,
			Object value1, String propertyName2, Object value2) {
		String hql="from UserRole where role.id=? and employee.sn=?";		
		List urList=super.getHibernateTemplate().find(hql,new Object[]{value1,value2});
		return urList;
	}

	public List<UserRole> findByProperty(String propertyName, Object value) {
		String hql="from UserRole ur where ur."+propertyName+"=?";
		return super.getHibernateTemplate().find(hql,value);
	}

	public List<Integer> findRoleIdByUid(String uid) {
		String hql="select ur.role.id from UserRole ur where ur.employee.sn=?";
		return super.getHibernateTemplate().find(hql,uid);
	}

	public void save(UserRole entity) {
		super.getHibernateTemplate().save(entity);

	}

}
